package dcx.utils
{
	import flash.display.DisplayObject;
	import flash.geom.Rectangle;
	
	public class DragComponent
	{
		public function DragComponent()
		{
		}
		
		private var mousex:Number;
		private var mousey:Number;
		private var dragObj:DisplayObject;
		private var dragRect:Rectangle;
		
		private var _isStart:Boolean;
		public function get isStart():Boolean
		{
			return _isStart;
		}
		public function startDrag(obj:DisplayObject, rect:Rectangle = null):void
		{
			if (_isStart) return;
			dragRect = rect;
			_isStart = true;
			mousex = obj.mouseX ;
			mousey = obj.mouseY;
			dragObj = obj;
		}
		public function dragMoving():void
		{
			if (_isStart)
			{
				var disX:Number = dragObj.mouseX - mousex;
				var disY:Number = dragObj.mouseY - mousey;
				dragObj.x = dragObj.x + disX;
				dragObj.y = dragObj.y + disY;
				
				
			}
		}
		public function stopDrag():void
		{
			_isStart = false;
			mousex = 0;
			mousey = 0;
			dragObj = null;
		}
	}
}